package gui;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.io.IOException;

import javax.swing.*;

public class MainWindowUI extends JFrame {

	private JPanel currentViewPane = null;
	
	public MainWindowUI() {		
		setSize(1000, 700);
		setPreferredSize(new Dimension(1000, 700));
		setTitle("TeamTime Manager");
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		
		setLayout(new BorderLayout());
		
		setJMenuBar(new MenuUI(this));
		
		TreePanelUI menuArea = new TreePanelUI();
		menuArea.setPreferredSize(new Dimension(300,700));
		
		add(menuArea, BorderLayout.WEST);
	}

	public void setViewPane(AbstractViewPane newViewPane) {
		
		if (currentViewPane != null) {
			this.remove(currentViewPane); /* Supprime l'ancienne vue */
		}
		
		currentViewPane = newViewPane;
		this.add(currentViewPane, BorderLayout.CENTER);

		this.validate(); /* Réactualise le contenu de la fenêtre */
	}


}
